package leetcode.code0984;

import leetcode.IDebug;

public class Solution implements IDebug {

	public String strWithout3a3b(int a, int b) {
		StringBuffer ans = new StringBuffer();
		while (a != 0 || b != 0) {
			if (a > b) {
				int add = Math.min(2, a - b);
				ans.append("a".repeat(add));
				a -= add;
				if (add == 2 && b > 0) {
					ans.append("b");
					b--;
				}
			} else if (b > a) {
				int add = Math.min(2, b - a);
				ans.append("b".repeat(add));
				b -= add;
				if (add == 2 && a > 0) {
					ans.append("a");
					a--;
				}
			} else {
				ans.append("a").append("b");
				a--;
				b--;
			}
		}
		return ans.toString();

	}

	@Override
	public void debug4() {
		System.out.println(this.strWithout3a3b(5, 2));
		System.out.println(this.strWithout3a3b(3, 4));
		System.out.println(this.strWithout3a3b(2, 5));
		System.out.println(this.strWithout3a3b(1, 4));
		System.out.println(this.strWithout3a3b(1, 3));
		System.out.println(this.strWithout3a3b(4, 1));
		System.out.println(this.strWithout3a3b(3, 1));
		// TODO Auto-generated method stub
	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

		System.out.println("b".repeat(0));

	}

}
